<template>
  <div class="wrapper">
    <!-- 头部区域 -->
    <div class="header-section">
      <div class="back-btn" @click="goBack">
        <i class="fa fa-angle-left"></i>
      </div>
      <h1 class="page-title">历史反馈信息列表</h1>
      <div class="action-icon" @click="toSelectGrid">
        <i class="fa fa-th"></i>
      </div>
    </div>

    <!-- 反馈列表卡片 -->
    <section class="feedback-card">
      <div class="card-body">
        <ul class="feedback-list">
          <li v-for="aqiFeedback in aqiFeedbackArr" :key="aqiFeedback.afId" class="feedback-item">
            <div class="feedback-header">
              <span class="aqi-tag" :style="{backgroundColor: aqiFeedback.aqi.color}">
                {{ aqiFeedback.aqi.chineseExplain }}
              </span>
              <span class="feedback-time">{{ aqiFeedback.afDate }} {{ aqiFeedback.afTime }}</span>
            </div>
            <div class="feedback-location">
              <div class="province">{{ aqiFeedback.gridProvince.provinceName }}</div>
              <div class="city">{{ aqiFeedback.gridCity.cityName }}</div>
            </div>
          </li>
        </ul>
      </div>
    </section>
  </div>
</template>

<script setup>
import { ref, inject } from "vue";
import { useRouter } from "vue-router";
import { getSessionStorage } from "../common.js";

const router = useRouter();
const axios = inject("axios");
const supervisor = getSessionStorage('supervisor');

const aqiFeedbackArr = ref([]);

const init = () => {
  axios
    .post("aqiFeedback/listAqiFeedbackByTelId", {
      telId: supervisor.telId
    })
    .then((response) => {
      aqiFeedbackArr.value = response.data;
    })
    .catch((error) => {
      console.log(error);
    });
}
init();

const toSelectGrid = () => {
  router.push('/selectGrid');
}
</script>

<script>
export default {
  methods: {
    goBack() {
      this.$router.push('/selectGrid')
    }
  }
}
</script>

<style scoped>
/* 基础布局 */
.wrapper {
  min-height: 100vh;
  width: 100%;
  max-width: 428px;
  margin: 0 auto;
  padding: 20px;
  background: url('../assets/hjbh.jpg') no-repeat center center / cover;
  font-family: 'PingFang SC', sans-serif;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-sizing: border-box;
}

/* 头部区域 */
.header-section {
  position: relative;
  width: 100%;
  padding: 10px 0;
  text-align: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.back-btn, .action-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s;
  user-select: none;
}
.back-btn { left: 0; }
.action-icon { right: 0; }
.back-btn:hover, .action-icon:hover {
  background: rgba(0,0,0,0.2);
}
.back-btn i, .action-icon i {
  color: #333;
  font-size: 20px;
  pointer-events: none;
}
.page-title {
  font-size: 32px;
  font-weight: 600;
  margin: 0 auto;
  color: #333;
  background: linear-gradient(135deg, #000000 0%, #e6e6e6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 
    1px 1px 1px rgba(255, 255, 255, 0.8),
    -1px -1px 1px rgba(0, 0, 0, 0.2);
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 反馈列表卡片 */
.feedback-card {
  width: 100%;
  max-width: 360px;
  background: rgba(255,255,255,0.95);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 20px;
  flex-grow: 1;
  overflow-y: auto;
  box-sizing: border-box;
}

/* 去掉.card-body的内边距让内容更贴合 */
.card-body {
  padding: 0;
}

/* 反馈列表样式 */
.feedback-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.feedback-item {
  display: flex;
  flex-direction: column;
  padding: 16px;
  margin-bottom: 16px;
  background: #f9f9f9;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.feedback-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* 反馈项头部 */
.feedback-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.aqi-tag {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  margin-right: 12px;
  white-space: nowrap;
}
.feedback-time {
  color: #666;
  font-size: 14px;
  white-space: nowrap;
}

/* 反馈项位置信息 */
.feedback-location {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.province, .city {
  flex: 1 1 45%;
  padding: 8px 12px;
  background: #f0f0f0;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
  text-align: center;
  word-break: break-word;
}
</style>
